package com.ruoyi.ftrl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ftrl.domain.RoomTemperature;
import com.ruoyi.ftrl.service.IRoomTemperatureService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 室温区间设定信息Controller
 * 
 * @author dihang
 * @date 2024-07-24
 */
@RestController
@RequestMapping("/ftrl/temperatures")
public class RoomTemperatureController extends BaseController
{
    @Autowired
    private IRoomTemperatureService roomTemperatureService;

    /**
     * 查询室温区间设定信息列表
     */
    @PreAuthorize("@ss.hasPermi('ftrl:temperatures:list')")
    @GetMapping("/list")
    public TableDataInfo list(RoomTemperature roomTemperature)
    {
        startPage();
        List<RoomTemperature> list = roomTemperatureService.selectRoomTemperatureList(roomTemperature);
        return getDataTable(list);
    }

    /**
     * 导出室温区间设定信息列表
     */
    @PreAuthorize("@ss.hasPermi('ftrl:temperatures:export')")
    @Log(title = "室温区间设定信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RoomTemperature roomTemperature)
    {
        List<RoomTemperature> list = roomTemperatureService.selectRoomTemperatureList(roomTemperature);
        ExcelUtil<RoomTemperature> util = new ExcelUtil<RoomTemperature>(RoomTemperature.class);
        util.exportExcel(response, list, "室温区间设定信息数据");
    }

    /**
     * 获取室温区间设定信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:temperatures:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(roomTemperatureService.selectRoomTemperatureById(id));
    }

    /**
     * 新增室温区间设定信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:temperatures:add')")
    @Log(title = "室温区间设定信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RoomTemperature roomTemperature)
    {
        return toAjax(roomTemperatureService.insertRoomTemperature(roomTemperature));
    }

    /**
     * 修改室温区间设定信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:temperatures:edit')")
    @Log(title = "室温区间设定信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RoomTemperature roomTemperature)
    {
        return toAjax(roomTemperatureService.updateRoomTemperature(roomTemperature));
    }

    /**
     * 删除室温区间设定信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:temperatures:remove')")
    @Log(title = "室温区间设定信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(roomTemperatureService.deleteRoomTemperatureByIds(ids));
    }
}
